home *** CD-ROM | disk | FTP | other *** search
- Path: nntphub.cb.att.com!not-for-mail
- From: ka@socrates.hr.att.com (Kenneth Almquist)
- Newsgroups: comp.lang.ada,comp.lang.c++,comp.lang.c
- Subject: Re: C++ vs Ada for large project
- Date: 9 Feb 1996 23:57:49 GMT
- Organization: AT&T Bell Laboratories, Columbus, Ohio
- Message-ID: <4fgn1t$ku8@nntpa.cb.att.com>
- References: <w4wx5wc1a2.fsf@cln46ac> <4ffjrq$i8k@qualcomm.com>
- NNTP-Posting-Host: socrates.hr.att.com
-
- Here is a real life story which illustrates why ".h" files are not
- a substitute for modules. A few years ago I was using a C++ compiler
- which came with some libraries and header files. Those of you
- familiar with UNIX know that UNIX provides a function which can be
- declared in C++ as
-
- extern "C" unsigned int alarm(unsigned int);
-
- A couple of these header files provided with the compiler contained
- the definition:
-
- extern "C" unsigned int alarm(unsigned long);
-
- This definition is incompatible with the definition of the UNIX alarm
- function, so if you included one of these header files in code which
- used the UNIX alarm function the compiler would reject it as an error.
-
- No real problem, you say. If you need to use the UNIX alarm function,
- just don't include the header files that misdefine it.
-
- This would be simple if C++ header files acted like modules, but they
- don't. Suppose you are writing two header files named a.h and b.h,
- and a.h needs to use a definition which appears in b.h. The way you
- accomplish this in C++ is to have a.h include b.h. The problem is
- that this has the effect of making a.h export all the names which are
- defined in b.h. As a result, the set of definitions exported by a C++
- header file often include definitions which have little in common with
- each other. And the misdefinitions of alarm (and several other UNIX
- system calls) were exported from some unpredicatable and suprising
- places.
-
- I was able to work around the problem, but probably spent a week doing
- it, and this was on a relatively small program. The larger the program,
- the harder header files are to manage.
- Kenneth Almquist
-